package main

import (
	"code/common/config"
	"code/common/grpc"
	"code/common/mysql"
	"os"
	"os/signal"
	"syscall"
)

func start() {
	config.LoadConfig()
	mysql.Start()
	grpc.Start()
}

func keepDaemon() {
	ch := make(chan os.Signal, 1)
	signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
	<-ch
}

func onClose() {
	mysql.Close()
	grpc.Stop()
}

func main() {
	start()
	defer onClose()
	keepDaemon()
}
